﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZOVNP.Model.Abstracts;

namespace ZOVNP.WinView
{
    public partial class UserEditControl : UserControl
    {
        private IUser _user;

        public UserEditControl(IUser user)
        {
            User = user;
            InitializeComponent();
        }

        public IUser User
        {
            get { return _user; }
            set
            {
                _user = value;

                tbxName.Text = _user != null ? _user.Name : string.Empty;
            }
        }

        private void tbxName_TextChanged(object sender, EventArgs e)
        {
            if (_user == null)
                throw new InvalidOperationException();

            _user.Name = tbxName.Text;
        }
    }
}
